package com.example.notice.news

import com.example.base.mvi.BaseViewModel
import com.example.base.mvi.HttpType
import com.example.base.net.ApiService
import dagger.hilt.android.lifecycle.HiltViewModel
import javax.inject.Inject

@HiltViewModel
class NewsViewModel @Inject constructor(val apiService: ApiService):BaseViewModel<NewsIntent>() {
    override fun handleIntent(it: NewsIntent) {
       when(it){
           NewsIntent.news -> {
                pageRequest({NewsDataSource(apiService)})
           }

           is NewsIntent.newsCancel -> {
               httpRequest(apiService.newsCancel(it.nid),HttpType.UPDATE)
           }
       }
    }
}